﻿using Newtonsoft.Json;
using RabbitMQ.Client;
using RabbitMQShare;
using System;
using System.Threading;

namespace RabbitMQConsumer
{
   public class Program
    {
        /***
         * 服务器充当消费者端，消费客户端发来的消息，即处理任务..
         * ***/




        private static RabbitMqModel _rabbitMqModel;
        static void Main(string[] args)
        {
            _rabbitMqModel = new RabbitMqModel()
            {
                Host="localhost",
                Port=5672,
                UserName="guest",
                PassWord="guest",
                QueueName="testQue1",
                ExchangeName="testExchange"
            };
            RabbitMQUtil.InitFactory(_rabbitMqModel);
            //Console.ReadKey();
            RabbitMQUtil.GetMsgFromQueue2<MessageModel>(_rabbitMqModel.QueueName);
            //Console.ReadKey();
            //while (true)
            //{
            //    RabbitMQUtil.InitFactory(_rabbitMqModel);

            //    MessageModel data = RabbitMQUtil.GetMsgFromQueue2<MessageModel>(_rabbitMqModel.QueueName, _rabbitMqModel.ExchangeName);
            //    string dataStr = JsonConvert.SerializeObject(data);
            //    //Console.WriteLine(dataStr);
            //    Thread.Sleep(3000);
            //}
            //Console.ReadKey();

        }
    }
}
